package com.dongdong.android.demo.ui.login;

import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.dongdong.android.framework.base.BaseActivity;
import com.dongdong.android.demo.R;
import com.dongdong.android.framework.http.requestentity.reqUserEntity;
import com.dongdong.android.framework.http.resultentity.BaseRsultEntity;
import com.dongdong.android.framework.http.resultentity.UserInfoEntity;
import com.dongdong.android.framework.utils.LogUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author dongdong
 * @date 2018/3/29
 */

public class LoginActivity extends BaseActivity<LoginPresenter, LoginModel> implements LoginContract.View {


    @BindView(R.id.login_activity_et_username)
    EditText mEtUserName;

    @BindView(R.id.login_activity_et_password)
    EditText mEtPassWord;

    @BindView(R.id.login_activity_tv_forget_pws)
     TextView mTvForget;

    @BindView(R.id.login_activity_tv_login)
     TextView mTvLogin;

    @BindView(R.id.login_activity_tv_register)
     TextView mTvRegister;


    @Override
    public int getLayoutId() {
        return R.layout.login_activity;
    }

    @Override
    public void initView() {
        ButterKnife.bind(this);


    }

    @Override
    public void initData() {

    }

    @Override
    public void initListener() {
        mTvLogin.setOnClickListener(this);
        mTvForget.setOnClickListener(this);
        mTvRegister.setOnClickListener(this);

    }

    @Override
    public void initPresenter() {
        mPresenter.setVM(this, mModel);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.login_activity_tv_login:
                Login();
                break;
            case R.id.login_activity_tv_forget_pws:
                break;
            case R.id.login_activity_tv_register:
                break;
            default:
                break;
        }

    }


    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }


    public void Login() {
        showProgressDialog();
        mPresenter.login(new reqUserEntity());
    }

    @Override
    public void onResultError(String error) {
        dismissProgressDialog();
        LogUtil.e(error);
    }

    @Override
    public void onLoginResult(BaseRsultEntity<UserInfoEntity> entity) {
        dismissProgressDialog();
    }
}
